package com.easy.common.constant;

/**
 * 是否删除
 * @author wyj
 */
public interface EnumConfig {

	enum S_CODE {
		OK(0, "成功[success]"),
		FAIL(1, "请求数据错误[request data failed)"),
		VALID_FAILED(2, "身份验证失败"),
		OVER_STOCK(4, "库存不足"),
		INPUT_ERROR(5, "输入有误"),
		NOT_PRODUCT(6, "宝贝不存在"),
		IN_PROMOTION(7, "已参加活动"),
		IS_FOLLOW(8, "已关注"),
		SALES_NOT_ENOUGH(9, "销量不足"),
		UPLOAD_FAILD(10, "上传文件失败"),
		NOT_ORDER(11, "订单不存在"),
		ORDER_STUTS_ERROR(12, "订单状态不符"),
		ORDER_NOT_USER(13, "该订单不属于该用户"),
		TUANGOU_OUT(14, "团购超出"),
		PARAM_ERROR(101, "参数错误[Parameter Error]"),
		USER_IS_DISABLED(102, "用户禁止登录[User is Disabled]"),
		IP_IS_MATCH(103, "登陆IP和用户绑定IP不符[Login IP and user bound IP does not match]"),
		USBKEY_LOGIN_FAIL(104, "使用USBKEY登录失败[USBKEY is failed]"),
		PASSWORD_ERROR(105, "密码错误[Password is Error]"),
		MOD_INIT_PASSWORD(106, "修改初始密码Modify Init Password"),
		PASSWORD_EXPIRED(107, "密码过期[Password Expired]"),
		RELOGIN_FAIL(108, "重新登录错误[Relogin Failed]"),
		TIME_OUT(111, "请求超时[Request Timeout}"),
		LIMIT(112, "请求受限[Request Limited]"),
		WAIT(113, "系统升级[System Upgrade]"),
		DYNAMIC_ENCRYPT_FAIL(114, "动态加密字符串有错[Dynamic Encryption String Failed]"),
		DYNAMIC_ENCRYPT_INTERNET_ERROR(115, "动态密码未知内部错误[request data failed]"),
		DYNAMIC_ENCRYPT_ERROR(116, "动态密码错误[request data failed]"),
		LIMIT_DATE(117, "已经超过最大免费试用期限[request data failed]"),
		VCODE_ERROR(118, "验证码错误[Verification Code Error]"),
		DB_ERROR(200, "数据库出错database exception"),
		NOT_METHOD(101, "not find the method"),
		NOT_LOGIN(102, "用户已经登录[user is not login]"),
		REPEAT(103, "Repeat"),
		NOT_BINDING(104, "User Not Bound"),
		NOT_USER(105, "用户不存在[User Does Not Exist]"),
		NOT_ROOM(106, "user not hava room"),
		IS_NULL(107, "不能为空[Contain Null]"),
		APIKEY_ERROR(300, "非法的apikey[Illegal apikey]"),
		SMS_FAILED(301, "发送失败[Send Failed]"),
		SMS_LIMIT(302, "发送超过限制[Send more than limit]"),
		MOBILE_ERROR(303, "无效的手机号[Invalid Mobile]"),
		OTHER_ERROR(999, "其他错误[Other Error]");

		private int code;
		private String name;

		S_CODE(int code, String name) {
			this.code = code;
			this.name = name;
		}

		public static S_CODE getEnum(int code) throws RuntimeException {
			S_CODE[] pesEnum = S_CODE.values();
			int len = pesEnum.length;
			for (int i = 0; i < len; i++) {
				if (pesEnum[i].getCode() == code) {
					return pesEnum[i];
				}
			}
			return null;
		}
		
		public int getCode() {
			return code;
		}
		public String getName() {
			return name;
		}
	}
}
